// EquipSortSelectorDoc.cpp: implementation of the EquipSortSelectorDoc class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "EquipSortSelectorDoc.h"

#include "PathManager.h"
#include "UEConnectionManager.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
typedef CArray<StdString,StdString> CStringArr;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

EquipSortSelectorDoc::EquipSortSelectorDoc()
{
	
}

EquipSortSelectorDoc::~EquipSortSelectorDoc()
{

}

CStringArr* EquipSortSelectorDoc::GetEquipFirIndex()
{
	StdString strSource = PathManager::Instance()->GetEquipSource();
    UEConnectionPtr m_pConnectPtr = UEConnectionManager::Instance().GetConnection(strSource);

	StdString strSQL = "select DISTINCT FirIndex from EquipIndex";
	UERecordsetPtr ptr = m_pConnectPtr->ExecuteSelectSQL(strSQL);
	
	CStringArr* strArr = new CStringArr;
	strArr->RemoveAll();
	if(ptr->IsEmpty())
	{
		return strArr;
	}
	ptr->MoveFirst();
	while(!ptr->IsEOF())
	{
		strArr->Add(ptr->GetString(_T("FirIndex")));
		ptr->MoveNext();
	}

	return strArr;

	
}
CStringArr* EquipSortSelectorDoc::GetEquipSecIndex(const StdString& strFirIndex)
{
	StdString strSource = PathManager::Instance()->GetEquipSource();
    UEConnectionPtr m_pConnectPtr = UEConnectionManager::Instance().GetConnection(strSource);

	StdString strSQL = "select * from EquipIndex where FirIndex = '"+strFirIndex+"' order by SecIndex";
	UERecordsetPtr ptr = m_pConnectPtr->ExecuteSelectSQL(strSQL);

	CStringArr* strArr = new CStringArr;
	strArr->RemoveAll();
	if(ptr->IsEmpty())
	{
	
		return strArr;
	}

	ptr->MoveFirst();
	while(!ptr->IsEOF())
	{
		strArr->Add(ptr->GetString(_T("SecIndex")));
		ptr->MoveNext();
	}

	
	return strArr;
}


CStringArr* EquipSortSelectorDoc::GetEquipImage(const StdString& strFirIndex)
{
	StdString strSource = PathManager::Instance()->GetEquipSource();
    UEConnectionPtr m_pConnectPtr = UEConnectionManager::Instance().GetConnection(strSource);

	StdString strSQL = "select * from EquipIndex where FirIndex = '"+strFirIndex+"' order by SecIndex";
	UERecordsetPtr ptr = m_pConnectPtr->ExecuteSelectSQL(strSQL);

	CStringArr* strArr = new CStringArr;
	strArr->RemoveAll();
	if(ptr->IsEmpty())
	{
		return strArr;
	}
	ptr->MoveFirst();
	while(!ptr->IsEOF())
	{
		StdString strTemp = ptr->GetString(_T("Icon"));
		strTemp = PathManager::Instance()->GetSystemPath() + strTemp;
		strArr->Add(strTemp);
		ptr->MoveNext();
	}
	return strArr;
}


StdString EquipSortSelectorDoc::GetEquipDefautIamge()
{
	StdString strPath = PathManager::Instance()->GetSystemPath();
	return strPath+"defaut.bmp";
    
}